using System;
using System.Collections.Generic;
using System.Text;

using Koossery.MVCwin.Actions.itf;
using Koossery.MVCwin.ControllerManager.itf;

namespace Koossery.MVCwin.Actions.impl
{
	/// <author>Mohamadou Yacoubou</author>
	/// <summary>
	/// The specific redirect to action result. It's invoke another controller's action
	/// </summary>
    /// <remarks>
    /// The class is marked as internal class, so that it's not accessible from a development project
    /// </remarks>
	internal class RedirectToActionResult : IActionResult
	{
		#region Fields

		/// <summary>
		/// The action name
		/// </summary>
		private string _actionName;

		/// <summary>
		/// The controller name
		/// </summary>
		private string _controllerName;

		#endregion Fields

		#region Constructors

		/// <summary>
		/// Constructor. The controller name and action name are injected using constructor injection
		/// </summary>
		/// <param name="controllerName">The name of the controller</param>
		/// <param name="actionName">The name of the actio</param>
		internal RedirectToActionResult(string controllerName, string actionName)
		{
			this._controllerName = controllerName;
			this._actionName = actionName;
		}

		#endregion Constructors

		#region Public Methods

		/// <summary>
		/// <see cref="IActionResult"/>
		/// </summary>
		/// <param name="manager"></param>
		public void ExecuteResult(IControllerManager manager)
		{
			//Execution de l'action
			manager.Invoke(_controllerName, _actionName);
		}

		#endregion Public Methods
	}
}